Skip to content

refactor(hash-aggr): Support spilling for single mode aggregation - #23965

Open
2010YOUY01 wants to merge 1 commit into
apache:mainfrom
2010YOUY01:split-aggr-spill-single
Open

refactor(hash-aggr): Support spilling for single mode aggregation#23965
2010YOUY01 wants to merge 1 commit into
apache:mainfrom
2010YOUY01:split-aggr-spill-single

Conversation

@2010YOUY01

@2010YOUY01 2010YOUY01 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #22710

Rationale for this change

This PR implements larger-than-memory execution for single mode aggregation.

See top comments at single_stream.rs for the high-level idea. The key implementations are in the same file.

What changes are included in this PR?

Are these changes tested?

Existing tests.

  • todo for myself: double check the codecov

Are there any user-facing changes?

No

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Jul 29, 2026
Field::new("b", DataType::Float64, false),
]));

let group_keys = [2, 3, 4, 4].repeat(1_000);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old implementation set a very tight memory budget, and the refactored implementation might have minor implementation difference, making this test fail.

Here it just try to scale up the test input size and memory limit, the test target is the same.

async fn test_aggregate_with_spill_if_necessary() -> Result<()> {
// test with spill
run_test_with_spill_pool_if_necessary(2_000, true).await?;
run_test_with_spill_pool_if_necessary(20_000, true).await?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the same as the previous note on test change.

matches!(root, DataFusionError::ResourcesExhausted(_)),
"Expected ResourcesExhausted, got: {root}",
);
let msg = root.to_string();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above check on error type is enough I think, here it also assert the exact error message

/// See comments at `poll_next()` for details.
///
/// Returns the next operator state with control flow decision.
fn handle_producing_output(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has no functional changes, the diffs are

  1. use internal_err instead of assert
  2. simplify some control flow code with break_with_err

SET datafusion.execution.target_partitions = 1

statement ok
SET datafusion.execution.batch_size = 128

@2010YOUY01 2010YOUY01 Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the above notes on the test change #23965 (comment)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.10627% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.75%. Comparing base (88365dd) to head (02636dd).
⚠️ Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
...sion/physical-plan/src/aggregates/single_stream.rs 83.84% 45 Missing and 8 partials ⚠️
datafusion/physical-plan/src/aggregates/mod.rs 33.33% 0 Missing and 6 partials ⚠️
...plan/src/aggregates/aggregate_hash_table/common.rs 86.95% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23965      +/-   ##
==========================================
+ Coverage   80.65%   80.75%   +0.09%     
==========================================
  Files        1093     1096       +3     
  Lines      371619   373556    +1937     
  Branches   371619   373556    +1937     
==========================================
+ Hits       299730   301659    +1929     
+ Misses      53993    53907      -86     
- Partials    17896    17990      +94     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants